package com.qq.server.view;

import com.qq.server.model.MyQqServer;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * @author weiBin
 * @date 2019/1/9
 */
public class MyServerJFrame extends JFrame implements ActionListener {
    JButton jbt1, jbt2;
    JPanel jpl1;

    public MyServerJFrame() {
        jbt1 = new JButton("开启服务器");
        jbt2 = new JButton("停止服务器");
        jbt1.addActionListener(this);
        jbt2.addActionListener(this);
        jpl1 = new JPanel();
        jpl1.add(jbt1);
        jpl1.add(jbt2);
        this.add(jpl1);
        this.setSize(500, 400);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setVisible(true);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        //如果是启动服务
        if (e.getSource() == jbt1) {
            MyQqServer.start();
        } else {
            MyQqServer.shutdown();
        }
    }

    public static void main(String[] args) {
        new MyServerJFrame();
    }
}
